package com.fingard.dsp.bank.directConfig;

import com.fingard.text.StringHelper;
import com.fingard.xml.XElement;

/**OSS设置，如果阿里云OSS*/
public class OssSet {
/**		    <bucket>za-electronicreceipt</bucket>
		    <endpoint>http://oss-cn-hzjbp-b-internal.aliyuncs.com</endpoint>
		    <accessKeyId>LTAI2b7mSW4zuneN</accessKeyId>
		    <accessKeySecret>bjXPxBtI8JIIZr2ulQzemMCFm2vzxJ</accessKeySecret>*/
	public String ossType;
	public String bucket;
	public String endpoint;
	public String accessKeyId;
	public String accessKeySecret;
	public String securityToken;
	public String objectKey;
	
	/**生成的OSS访问该文件Url的有效天数*/
	public int urlLimitDays;
	
	public OssSet(){
		bucket = "";
		endpoint = "";
		accessKeyId = "";
		accessKeySecret = "";
		ossType = "";
		urlLimitDays = 31;
	}
	
	public void fromXElement(XElement p_xe) throws Exception{
		ossType = p_xe.getSingleTextNotNull("ossType");
		bucket = p_xe.getSingleTextNotNull("bucket");
		endpoint = p_xe.getSingleTextNotNull("endpoint");
		accessKeyId = p_xe.getSingleTextNotNull("accessKeyId");
		accessKeySecret = p_xe.getSingleTextNotNull("accessKeySecret");
		String limitDays = p_xe.getSingleTextNotNull("urlLimitDays");
		if(StringHelper.hasAnyChar(limitDays)){
			urlLimitDays = Integer.parseInt(limitDays);
		}
	}
}
